import axios from "axios";
import { loginUserStore } from '../store/index'

// const userStore = loginUserStore()
const myaxios = axios.create({
    baseURL: 'http://localhost:8888/api/private/v1',
})

//拦截器
myaxios.interceptors.request.use((config: any) => {
    if (config.url !== '/login') {
        //登录之后才能获取token
        // config.headers.Authorization = userStore.userinfo.token;
        const token = JSON.parse(String(localStorage.getItem('userinfo'))).token
        config.headers.Authorization = token;
    }

    return config
    //app.config.globalProperties.$axios = instance;
})
export { myaxios }